package com.ruoyi.web.controller.system;

import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.ruoyi.system.domain.vo.ProjectManageRemarkRespVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProjectManageRemark;
import com.ruoyi.system.service.IProjectManageRemarkService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目管理评论Controller
 *
 * @author ruoyi
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/system/remark")
public class ProjectManageRemarkController extends BaseController {
    @Autowired
    private IProjectManageRemarkService projectManageRemarkService;

    /**
     * 查询项目管理评论列表
     */
    //@PreAuthorize("@ss.hasPermi('system:remark:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(ProjectManageRemark projectManageRemark) {
//        startPage();
//        List<ProjectManageRemark> list = projectManageRemarkService.selectProjectManageRemarkList(projectManageRemark);
//        return getDataTable(list);
//    }
    @GetMapping("/list")
    public AjaxResult list(ProjectManageRemark projectManageRemark) {
        return success(projectManageRemarkService.getList(projectManageRemark));
    }

    /**
     * 获取项目管理评论详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:remark:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(projectManageRemarkService.selectProjectManageRemarkById(id));
    }

    /**
     * 新增项目管理评论
     */
    //@PreAuthorize("@ss.hasPermi('system:remark:add')")
    @Log(title = "项目管理评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectManageRemark projectManageRemark) {
        return toAjax(projectManageRemarkService.insertProjectManageRemark(projectManageRemark));
    }

    /**
     * 修改项目管理评论
     */
    @PreAuthorize("@ss.hasPermi('system:remark:edit')")
    @Log(title = "项目管理评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectManageRemark projectManageRemark) {
        return toAjax(projectManageRemarkService.updateProjectManageRemark(projectManageRemark));
    }

    /**
     * 删除项目管理评论
     */
    @PreAuthorize("@ss.hasPermi('system:remark:remove')")
    @Log(title = "项目管理评论", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(projectManageRemarkService.deleteProjectManageRemarkByIds(ids));
    }
//
//    private List<ProjectManageRemarkRespVO> list(){
//        String str = "[\n" +
//                "    {\n" +
//                "        \"name\": \"Lana Del Rey\",\n" +
//                "        \"id\": 19870621,\n" +
//                "        \"comment\": \"我发布一张新专辑Norman Fucking Rockwell,大家快来听啊\",\n" +
//                "        \"time\": \"2019年9月16日 18:43\",\n" +
//                "        \"commentNum\": 2,\n" +
//                "        \"like\": 15,\n" +
//                "        \"inputShow\": false,\n" +
//                "        \"reply\": [\n" +
//                "            {\n" +
//                "                \"from\": \"Taylor Swift\",\n" +
//                "                \"fromId\": 19891221,\n" +
//                "                \"to\": \"Lana Del Rey\",\n" +
//                "                \"toId\": 19870621,\n" +
//                "                \"comment\": \"我发布一张新专辑Norman Fucking Rockwell,大家快来听啊\",\n" +
//                "                \"time\": \"2019年9月16日 18:43\",\n" +
//                "                \"commentNum\": 1,\n" +
//                "                \"like\": 15,\n" +
//                "                \"inputShow\": false\n" +
//                "            },\n" +
//                "            {\n" +
//                "                \"from\": \"Ariana Grande\",\n" +
//                "                \"fromId\": 1123,\n" +
//                "                \"to\": \"Lana Del Rey\",\n" +
//                "                \"toId\": 19870621,\n" +
//                "                \"comment\": \"别忘记宣传我们的合作单曲啊\",\n" +
//                "                \"time\": \"2019年9月16日 18:43\",\n" +
//                "                \"commentNum\": 0,\n" +
//                "                \"like\": 5,\n" +
//                "                \"inputShow\": false\n" +
//                "            }\n" +
//                "        ]\n" +
//                "    },\n" +
//                "    {\n" +
//                "        \"name\": \"Taylor Swift\",\n" +
//                "        \"id\": 19891221,\n" +
//                "        \"comment\": \"我发行了我的新专辑Lover\",\n" +
//                "        \"time\": \"2019年9月16日 18:43\",\n" +
//                "        \"commentNum\": 1,\n" +
//                "        \"like\": 5,\n" +
//                "        \"inputShow\": false,\n" +
//                "        \"reply\": [\n" +
//                "            {\n" +
//                "                \"from\": \"Lana Del Rey\",\n" +
//                "                \"fromId\": 19870621,\n" +
//                "                \"to\": \"Taylor Swift\",\n" +
//                "                \"toId\": 19891221,\n" +
//                "                \"comment\": \"新专辑和speak now 一样棒！\",\n" +
//                "                \"time\": \"2019年9月16日 18:43\",\n" +
//                "                \"commentNum\": 25,\n" +
//                "                \"like\": 5,\n" +
//                "                \"inputShow\": false\n" +
//                "            }\n" +
//                "        ]\n" +
//                "    },\n" +
//                "    {\n" +
//                "        \"name\": \"Norman Fucking Rockwell\",\n" +
//                "        \"id\": 20190830,\n" +
//                "        \"comment\": \"Plz buy Norman Fucking Rockwell on everywhere\",\n" +
//                "        \"time\": \"2019年9月16日 18:43\",\n" +
//                "        \"commentNum\": 0,\n" +
//                "        \"like\": 5,\n" +
//                "        \"inputShow\": false,\n" +
//                "        \"reply\": []\n" +
//                "    }\n" +
//                "]";
//        ArrayList<ProjectManageRemarkRespVO> list = new ArrayList<>();
//        JSONArray jsonArray = JSONUtil.parseArray(str);
//        for (Object o : jsonArray) {
//            ProjectManageRemarkRespVO projectManageRemarkRespVO = JSONUtil.toBean(o.toString(), ProjectManageRemarkRespVO.class);
//            list.add(projectManageRemarkRespVO);
//        }
//        return list;
//    }
}
